package cate.game.play.skill.passive.guild;

import cate.common.table.d.GDAttr;
import cate.common.table.d.GDSkill;
import cate.game.play.base.TargetFilterParam;
import cate.game.play.base.TargetSelector;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.fighter.Fighter;
import cate.game.play.proce.action.ctx.ActionCtx;
import cate.game.play.skill.passive.PassiveHandler;

/**
 * 奇数回合为生命值最低的3名友方单位附加【乾天罡气】
 */
public class 乾天罡气PH extends PassiveHandler {

	private int 人数;

	private int buff;

	//人数=3&buff=??
	@Override
	public void parse(String code) {
		PlayCfgArgs args = new PlayCfgArgs(code);
		人数 = args.getInt("人数", 0);
		buff = args.getInt("buff", 0);
	}

	@Override
	public void onRoundBegin(ActionCtx action) {
		if (skill.owner.isDead()) {
			return;
		}
		if (action.getRound().isOddRound()) {
			TargetFilterParam param = new TargetFilterParam().scopeSet(GDSkill.Scope.WE).targetNumSet(人数).smallAttrSet(GDAttr.V_HP_LEFT);
			for (Fighter fighter : TargetSelector.doFind(skill.owner, action.getTeamVs(), param)) {
				fighter.buff.tryAddByTid(action, skill.owner, buff);
			}
		}
	}
}
